;Copyright (C) 2011 Salil Bhagurkar
;
;This file is part of illusion
;
;illusion is free software: you can redistribute it and/or modify
;it under the terms of the GNU Lesser General Public License as published by
;the Free Software Foundation, either version 3 of the License, or
;(at your option) any later version.
;
;illusion is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU Lesser General Public License for more details.
;
;You should have received a copy of the GNU Lesser General Public License
;along with illusion.  If not, see <http://www.gnu.org/licenses/>.


[BITS 32]
[section .text]

;Default loader for Illusion applications

global __get_interface ;(char *name, void **interface);
__get_interface:
	push ebp
	mov ebp, esp

	push dword[ebp + 12]
	push dword[ebp + 8]
	mov eax, [__get_interface_address]
	call eax
	add esp, 8

	pop ebp
	ret

init_ilapp:
	mov eax, 13 ;SYS_GETAPIMOD
	mov ebx, __get_interface_address
	int 0x80
	ret

global __ilapp_load
__ilapp_load:
	call init_ilapp

	extern _ilapp_main
	call _ilapp_main

	;Exit this process
	mov eax, 20
	mov ebx, 0
	int 0x80

[section .data]
__get_interface_address dd 0
